#define X_UNIT 0.02f
#define Y_UNIT 0.02f
#define dt 0.001f
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void)
{
    FILE *fd;
    int sigma_x=0,sigma_y=0;
    int delta_x = 0,delta_y = 0;
    int m_x,m_y;
    unsigned int r = 5;
    unsigned int F = 600;
    int x0=0,y0=5,x1=-5,y1=0,temp_x0,temp_y0;
    if((fd = fopen("./point.txt","w+")) == NULL)
    {
        return -1;
    }
    x0 = x0/X_UNIT;
    y0 = y0 / Y_UNIT;
    x1 = x1/X_UNIT;
    y1 = y1/Y_UNIT;
    m_x = r/dt/(F/60);
    m_y = r/dt/(F/60);
    delta_x = abs(x1-x0);
    delta_y = abs(y1-y0);
    fprintf(fd,"x,y\n");
    fprintf(fd,"%d,%d\n",x0,y0);
    while((delta_x > 0) || (delta_y > 0))
    {
        temp_x0 = x0;temp_y0 = y0;
        if(delta_x > 0)
        {
            sigma_x -= temp_y0;
            if(sigma_x < (0-m_x))
            {
                sigma_x += m_x;
                x0--;
                delta_x --;
            }
            else if(sigma_x > m_x)
            {
                sigma_x -= m_x;
                x0++;
                delta_x --;
            }
            else{}
        }
        if(delta_y > 0)
        {
            sigma_y += temp_x0;
            if(sigma_y > m_y)
            {
                sigma_y -= m_y;
                y0++;
                delta_y--;
            }
            else if(sigma_y < (0-m_y))
            {
                sigma_y += m_y;
                y0--;
                delta_y--;
            }
            else{}
        }
        fprintf(fd,"%d,%d\n",x0,y0);
    }
    fprintf(fd,"%d,%d\n",x1,y1);
    fclose(fd);

    return 0;
}